package com.hank.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hank.entity.User;
import com.hank.service.IUserService;
import com.hank.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author hank
 * @since 2023-04-23
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户相关接口")
public class UserController {

    @Resource
    IUserService userService;

    //分页查询所有用户接口
    @ApiOperation("分页查询用户")
    @GetMapping("/userPage")
    public R getPageUser(@RequestParam(name = "current")int current,
                         @RequestParam(name = "size")int size){
        return userService.getUserPage(current,size);
    }

    @ApiOperation("查询用户信息")
    @GetMapping("/userInfo")
    public R getUserInFo(@RequestParam(name = "id")int id){
        User user = userService.getById(id);
        return R.ok().put("result",user);
    }





}
